<?php session_start();?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Detail</title>
        <link rel="stylesheet" type="text/css" title="T1" href="stylesheet/progin.css" id="link_theme" />
        <link rel="stylesheet" type="text/css" title="T1" href="stylesheet/detail.css" />
		<meta name="description" content="RER Gag, Make You Laughing" />
		<meta name="keywords" content="laugh" />
		<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
                <script type="text/javascript" src="script/home.js"></script>
    </head>
    <body>
        <?php include 'header.php'; ?>
            
        <div class="main_container">


            <?php
            $con = mysql_connect("localhost","root","");
            if (!$con)
            {
                die('Could not connect: ' . mysql_error());
            }

            mysql_select_db("progin_171_13509008", $con);

            // get session id_content which we want to display
            $id_temp = $_SESSION['id_content'];
            $queryDetilContent = "Select title,id_content as id_konten,content_type, content_filled, content_description, posting_time, user_name from content where id_content = $id_temp";
            $resultSelect = mysql_query($queryDetilContent);

            
            while ($row = mysql_fetch_array($resultSelect)){
                if($row['content_type']== 'link'){
                    echo "<h1>".$row['title']."</h1>";
                    echo "<h2>".$row['content_filled']."</h2>";
                    echo "<h3>".$row['content_description']."</h3>";
                    echo "<h3>Posted by: <a href='detail.php'>".$row['user_name']."</a></h3>";
                }
                if($row['content_type']== 'image'){
                    echo "<h1>".$row['title']."</h1>";
                    echo "<img src='".$row['content_filled']."' height=500px; ></img>";
                    echo "<h3>Posted by: <a href='detail.php'>".$row['user_name']."</a></h3>";
                }
                if($row['content_type']== 'video'){
                    echo "<h1>".$row['title']."</h1>";
                    echo $row['content_filled'];
                    echo "<h3>Posted by: <a href='detail.php'>".$row['user_name']."</a></h3>";
                }

                  echo"<input id='like_".$row['id_konten']."' class='like_button' type='image' src='images/like_button.jpg' onclick='like(\"".$_SESSION['user_name']."\",".$row['id_konten'].")'/>";
                   echo"<input class='total_like_class' type='text' disabled='disabled' id='total_like_".$row['id_konten']."' />";
                   echo"<input id='dislike_'".$row['id_konten']." class='like_button' type='image' src='images/dislike_button.jpg' onclick='dislike(\"".$_SESSION['user_name']."\",".$row['id_konten'].")'/>";
                   echo"<input class='total_dislike_class' type='text' disabled='disabled' id='total_dislike_".$row['id_konten']."' />";

                      echo"<script type='text/javascript'>"; //hitung nilai like dan dislike dulu!
                   echo "likeUpdater(".$row['id_konten']."); dislikeUpdater(".$row['id_konten'].");";
                   echo "</script>";
            }

            // show time Posting
            $queryGetTime = "SELECT CONCAT(
                                FLOOR(HOUR(TIMEDIFF(posting_time, NOW())) / 24), ' days ',
                                MOD(HOUR(TIMEDIFF(posting_time, NOW())), 24), ' hours ',
                                MINUTE(TIMEDIFF(posting_time, NOW())), ' minutes') as time_difference
                                from content where id_content=$id_temp";
            $resultTime= mysql_query($queryGetTime);

            while ($rowres = mysql_fetch_array($resultTime)){
                echo "Posting Time:  ".$rowres['time_difference']." ago<br/>";
            }

            include 'getComment.php';
            ?>
        <script type="text/javascript" src="script/detail.js"></script>
        <script type="text/javascript" src="script/progin.js"></script>
        </div>
    </body>
</html>
